/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.sql.Timestamp;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.CascadeType;
import javax.persistence.OneToOne;

/**
 *
 * @author Ee Ting
 */
@Entity
public class ProdRecordMRP implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long prodRecordMRPId;
    @OneToOne(cascade = {CascadeType.PERSIST})
    private Product prod;
    private int mpsCaseFig;
    private int mpsKgFig;
    @OneToOne(cascade = {CascadeType.PERSIST})
    private SystemUser createdBy;
    private Timestamp createdDate;
    
    public void create(Product product, int caseFig, int kgFig,SystemUser user)
    {
        this.setProd(product);
        this.setMpsCaseFig(caseFig);
        this.setMpsKgFig(kgFig);
        this.setCreatedBy(user);
        java.util.Date tmp = new java.util.Date();
        this.setCreatedDate(new Timestamp(tmp.getTime()));
    }

    public SystemUser getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(SystemUser createdBy) {
        this.createdBy = createdBy;
    }

    public Timestamp getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Timestamp createdDate) {
        this.createdDate = createdDate;
    }

    public int getMpsCaseFig() {
        return mpsCaseFig;
    }

    public void setMpsCaseFig(int mpsCaseFig) {
        this.mpsCaseFig = mpsCaseFig;
    }

    public int getMpsKgFig() {
        return mpsKgFig;
    }

    public void setMpsKgFig(int mpsKgFig) {
        this.mpsKgFig = mpsKgFig;
    }

    public Product getProd() {
        return prod;
    }

    public void setProd(Product prod) {
        this.prod = prod;
    }

    public Long getProdRecordMRPId() {
        return prodRecordMRPId;
    }

    public void setProdRecordMRPId(Long id) {
        this.prodRecordMRPId = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (prodRecordMRPId != null ? prodRecordMRPId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ProdRecordMRP)) {
            return false;
        }
        ProdRecordMRP other = (ProdRecordMRP) object;
        if ((this.prodRecordMRPId == null && other.prodRecordMRPId != null) || (this.prodRecordMRPId != null && !this.prodRecordMRPId.equals(other.prodRecordMRPId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.ProdRecordMPR[ id=" + prodRecordMRPId + " ]";
    }
    
}
